<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>
    <div class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
        <?php } ?>
    </div>
    <div id="community">
    <link href="catalog/view/theme/default/stylesheet/jquery.rating.css" type="text/css" rel="stylesheet"/>
    <script type="text/javascript" src="catalog/view/javascript/jquery/jquery.rating.pack.js"></script>
        <div id="forum-header">
            <?php echo $community_header; ?>
            <?php if ($text_forum_points_awarded) { ?>
            <div class="success" id="forum-points-awarded"><?php echo $text_forum_points_awarded; ?><img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>
            <?php } ?>
            <?php if ($rating_success) { ?>
            <div class="success"><?php echo $rating_success; ?><img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>
            <?php } ?>
            <?php if ($claim_success) { ?>
            <div class="success"><?php echo $claim_success; ?><img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>
            <?php } ?>
            <?php if ($claim_fail) { ?>
            <div class="warning"><?php echo $claim_fail; ?><img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>
            <?php } ?>
            <div>
                <h1>
                    <a href="<?php echo $headline_link; ?>"><?php echo $topic['topic_title']; ?></a>
                    <?php if($this->data['topic']['topic_solved']){ ?>
                    &nbsp;&nbsp;<img style="vertical-align:middle;" src="catalog/view/theme/default/image/post/icon_topic_solved_topic.png" />
                    <a style="float:none; font-size:11px;color:#BC2A4D;" href="<?php echo $answer_post_link; ?>"><?php echo $text_view_answer_post; ?></a>
                    <?php } ?>
                    <?php if($is_user_login){ ?>
                    <form action="<?php echo $subscribe_bookmark_action_link; ?>" method="post">
                        <input type="submit" id="<?php echo $text_subsribe_name; ?>" name="<?php echo $text_subsribe_name; ?>" value="<?php echo $text_subscribe; ?>" title="<?php echo $text_subscribe; ?>" />
                        <input type="submit" id="<?php echo $text_bookmark_name; ?>" name="<?php echo $text_bookmark_name; ?>" value="<?php echo $text_bookmark; ?>" title="<?php echo $text_bookmark; ?>" />
                    </form>
                    <?php } ?>
                </h1>
                <?php if($allow_reply){ ?>
                <a class="reply-button" href="<?php echo $new_reply_link; ?>"></a>
                <?php } ?>
                <div class="forum-pagination"><?php echo $entry_jump; ?>&nbsp;<input type="text" name="page_num" value="" onkeydown="if(event.keyCode==13) {window.location='<?php echo $headline_link; ?>&page='+this.value; return false;}" /><input class="input-buttons" style="height:22px;" type="button"  value="<?php echo $text_go; ?>" onclick="window.location='<?php echo $headline_link; ?>&page=' + $('input[name=\'page_num\']').attr('value');" /><?php echo $pagination; ?></div>
            </div>
        </div>
        <?php if($topic['cart_product_id']){ ?>
        <div id="topic-product">
            <dl>
                <dt><img src="<?php echo $topic['topic_product_image']; ?>" /></dt>
                <dd><a href="<?php echo $topic['product_link']; ?>" target="_blank"><?php echo $topic['product_name']; ?></a></dd>
                <dd><strong><?php echo $text_sku; ?></strong><?php echo $topic['model']; ?></dd>
                <?php if($topic['price']){ ?>
                <dd><strong><?php echo $text_price; ?></strong><span><?php echo $topic['price']; ?></span></dd>
                <?php } ?>
                <dd><strong><?php echo $text_availability; ?></strong><?php echo $topic['availability']; ?></dd>
                <dd><strong><?php echo $text_reward_points; ?></strong><span><?php echo $topic['points']; ?></span></dd>
                <dd><a href="<?php echo $topic['product_link']; ?>" target="_blank"><strong><?php echo $text_view; ?></strong></a></dd>
                <dd><em><?php echo $text_note;; ?></em></dd>
            </dl>
        </div>
        <?php } ?>
        <?php if($topic['topic_polled']){ ?>
        <div id="topic-poll">
            <form action="<?php echo $poll_action; ?>" method="POST">
            <dl>
                <dd id="poll-title"><?php echo $topic['poll_title']; ?></dd>
                <dd id="poll-rum-time">
                    <span><?php echo $topic['poll_run_time']; ?></span>
                    <?php if($user_can_vote && $user_has_not_voted && $ip_has_not_voted){ ?>
                    <em><?php echo $text_poll_max_options; ?></em>
                    <?php } ?>
                    <?php echo $text_total_votes; ?>
                    <?php if($show_count_down){ ?>
                    <div id="counter_poll"></div>
                    <?php } ?>
                </dd>
                <?php foreach($polls as $poll){ ?>
                <dd class="poll-option">
                    <dl>
                        <dd class="poll-option-text"><?php echo $poll['poll_option_text']; ?></dd>
                        <?php if(!$poll_end && $user_can_vote && $user_has_not_voted && $ip_has_not_voted){ ?>
                        <dd>
                            <?php if($topic['poll_max_options']>1){ ?>
                            <input type="checkbox" name="poll_option[]" value="<?php echo $poll['poll_option_id']; ?>" <?php echo $poll['is_option_selected']; ?> />
                            <?php }else{ ?>
                            <input type="radio" name="poll_option" value="<?php echo $poll['poll_option_id']; ?>" <?php echo $poll['is_option_selected']; ?> />
                            <?php } ?>
                        </dd>
                        <?php } ?>
                        <dd><div style="width:<?php echo $poll['poll_option_bar_width']; ?>;"><?php echo $poll['poll_option_total']; ?></div></dd>
                        <dd><?php echo $poll['poll_option_percentage']; ?></dd>
                    </dl>
                </dd>
                <?php } ?>
                <?php if(!$poll_end && $user_can_vote && $user_has_not_voted && $ip_has_not_voted){ ?>
                <dd class="center-up"><input class="input-buttons" type="submit" name="submit_vote" value="<?php echo $button_submit_vote; ?>" /> </dd>
                <?php } ?>
            </dl>
            </form>
        </div>
        <?php } ?>
        <?php $i=0; ?>
        <?php foreach($posts as $post){ ?>
        <div class="view-topic <?php echo $odd_even_post[$i]; ?> <?php echo $show_reported_post_style[$i] ? 'reported-post' :''; ?> <?php echo $post['is_online'] ? 'post-user-online' : ''; ?>">
            <form name="post-action" action="<?php echo $post_action_link; ?>" method="post">
            <dl class="topic-left">
                <dd class="left-header">
                    <h2>
                        <a href="<?php echo $title_link . '#' . $post['post_id']; ?>" name="<?php echo $post['post_id']; ?>"><?php echo $post['post_subject']; ?></a>
                        <?php if($this->data['topic']['topic_answer_post_id']==$post['post_id']){ ?>
                        <img style="vertical-align:middle; margin-left:10px;" src="catalog/view/theme/default/image/post/icon_topic_solved_post.png" />
                        <?php } ?>
                    </h2>
                    <dl class="post-icons">
                        <?php if($is_user_login){ ?>
                        <?php if($show_report_icon[$i]){ ?>
                        <dd class="report-post"><a href="<?php echo $report_post_link[$i]; ?>" title="<?php echo $text_report_post; ?>"></a></dd>
                        <?php } ?>
                        <?php if($show_delete_icon[$i]){ ?>
                        <dd class="delete-post">
                            <input type="submit" name="delete-submit" value="<?php echo $text_delete_post; ?>" title="<?php echo $text_delete_post; ?>" onclick="{if(confirm('<?php echo $text_confirm_delete; ?>')){this.document.post-action.submit();return true;}return false;}" />
                            <input type="hidden" name="pid" value="<?php echo $post['post_id']; ?>" />
                        </dd>
                        <dd class="reply-quote"><a href="<?php echo $quote_post_link[$i]; ?>" title="<?php echo $text_reply_quote; ?>"></a></dd>
                        <?php } ?>
                        <?php if($show_edit_icon[$i]){ ?>
                        <dd class="edit-post"><a href="<?php echo $edit_post_link[$i]; ?>" title="<?php echo $text_edit_post; ?>"></a></dd>
                        <?php } ?>
                        <?php if($show_solve_icon[$i]){ ?>
                        <dd class="solve-post">
                            <input type="submit" name="solve-submit" value="<?php echo $text_solve_post; ?>" title="<?php echo $text_solve_post; ?>" onclick="{if(confirm('<?php echo $text_confirm_solve; ?>')){this.document.post-action.submit();return true;}return false;}" />
                            <input type="hidden" name="pid" value="<?php echo $post['post_id']; ?>" />
                            <input type="hidden" name="uid" value="<?php echo $post['poster_id']; ?>" />
                        </dd>
                        <?php } ?>
                        <?php if($show_unsolve_icon[$i]){ ?>
                        <dd class="unsolve-post">
                            <input type="submit" name="unsolve-submit" value="<?php echo $text_unsolve_post; ?>" title="<?php echo $text_unsolve_post; ?>" onclick="{if(confirm('<?php echo $text_confirm_unsolve; ?>')){this.document.post-action.submit();return true;}return false;}" />
                            <input type="hidden" name="pid" value="<?php echo $post['post_id']; ?>" />
                        </dd>
                        <?php } ?>
                        <?php if($show_thank_icon[$i]){ ?>
                        <dd class="thank-post">
                            <input type="submit" name="thank-submit" value="<?php echo $text_thank_post; ?>" title="<?php echo $text_thank_post; ?>" onclick="{if(confirm('<?php echo $text_confirm_thank; ?>')){this.document.post-action.submit();return true;}return false;}" />
                            <input type="hidden" name="pid" value="<?php echo $post['post_id']; ?>" />
                            <input type="hidden" name="uid" value="<?php echo $post['poster_id']; ?>" />
                        </dd>
                        <?php } ?>
                        <?php } ?>
                    </dl>
                </dd>
                <dd class="left-poster">
                    <?php echo $text_by; ?>&nbsp;<a href="<?php echo $post['user_link']; ?>"><?php echo $post['post_username']; ?></a>&nbsp;&raquo;&nbsp;<?php echo $post['post_time'] ?>
                    <?php if($post['post_rating']){ ?>
                    <img style="margin:0 5px 0 20px;vertical-align:middle;" src="catalog/view/theme/default/image/stars-<?php echo $post['post_rating']; ?>.png" />
                    <?php echo $post['based_on']; ?>
                    <?php } ?>
                    <?php if($show_rating_icon[$i]){ ?>
                    <div>
                        <input class="star required" type="radio" name="rating" value="1" title="<?php echo $text_very_poor; ?>" />
                        <input class="star" type="radio" name="rating" value="2" title="<?php echo $text_poor; ?>" />
                        <input class="star" type="radio" name="rating" value="3" title="<?php echo $text_ok; ?>" />
                        <input class="star" type="radio" name="rating" value="4" title="<?php echo $text_good; ?>" />
                        <input class="star" type="radio" name="rating" value="5" title="<?php echo $text_gorgeous; ?>" />
                        <input id="rate-post" type="submit" name="rate-post" value="Rate" />
                        <input type="hidden" name="pid" value="<?php echo $post['post_id']; ?>" />
                    </div>
                    <?php } ?>
                </dd>
                <dd class="left-contents">
                    <?php if($show_reported_post_style[$i]){ ?>
                    <div class="reported-post-bar">
                       <a href="<?php echo $post['view_report_link']; ?>"> <strong><?php echo $text_view_report; ?></strong></a>
                    </div>
                    <?php } ?>
                    <?php echo $post['post_contents']; ?>
                    <?php if($is_your_day_topic && $i==0) {?>
                    <div style="margin:20px 0 10px 250px;" id="your-day"></div>
                    <?php if(!$is_claim_ended){ ?>
                    <?php if($is_user_login) {?>
                    <input class="input-buttons" style="width:180px; margin-left:250px;" type="submit" name="your-day-submit" value="<?php echo $button_claim; ?>" /><br /><br />
                    <?php }else{ ?>
                    <span style="margin-left:200px;font-weight:bold; color:#FF0000;"><?php echo $text_login_to_claim; ?></span><br /><br />
                    <?php } ?>
                    <?php }else{ ?>
                    <span style="margin-left:200px;font-weight:bold;"><?php echo $text_claim_end; ?></span><br /><br />
                    <?php } ?>
                    <strong><?php echo $text_participant ?></strong>
                    <?php if($participants){ ?>
                    <?php foreach($participants as $participant){ ?>
                     <a href="<?php echo $participant['participant_link']; ?>"><?php echo $participant['participant_name']; ?></a>&nbsp;&nbsp;
                    <?php } ?>
                    <?php }else{ ?>
                    <?php echo $text_no_participant; ?>
                    <?php } ?>
                    <input type="hidden" name="name-id" value="<?php echo $your_day_name_id ?>" />
                    <?php } ?>
                </dd>
                <?php if($post['post_edit_count']){ ?>
                <dd class="left-edit-reason">
                    <?php echo $post['text_post_edit_remark'];?>
                    <?php if(!empty($post['post_edit_reason'])){ ?>
                        <br /><?php echo $post['text_post_edit_reason'];?>
                        <?php } ?>
                </dd>
                <?php } ?>
                <?php if($post['enable_sig'] && $post['user_sig'] ){ ?>
                <dd class="left-signature"><?php echo $post['user_sig']; ?></dd>
                <?php } ?>
                <?php if($post['thanks_received']){ ?>
                <dd class="left-thanks">
                    <?php echo $text_thanks_received; ?>
                    <?php echo $post['thanks_received']; ?><br />
                    <?php echo $text_thanks_givers; ?>
                    <?php $t=0; ?>
                    <?php foreach($post['thanks_giver_usernames'] as $thanks_giver_name){ ?>
                        <a href="<?php echo $post['thanks_giver_links'][$t]; ?>"><?php echo $thanks_giver_name; ?></a>&nbsp;
                        <?php if($t==9) {?>
                        <?php break; ?>
                        <?php } ?>
                        <?php $t++ ?>
                    <?php } ?>
                    <?php if(isset($text_thank_other_givers)){ ?>
                        <?php echo $text_thank_other_givers; ?>
                    <?php } ?>
                </dd>
                <?php } ?>
            </dl>
            </form>
            <dl class="topic-right">
                <a style="float:right;margin-right:5px;margin-top:-10px;" href="<?php echo $post['post_num_link']; ?>"><?php echo '#' . $post['post_num']; ?></a>
                <?php if($post['user_avatar']){ ?>
                <dd><img src="<?php echo $post['user_avatar']; ?>" /></dd>
                <?php } ?>
                <dd><a href="<?php echo $post['user_link']; ?>"><?php echo $post['post_username']; ?></a></dd>
                <dd><?php echo $post['user_title']; ?></dd>
                <?php if($post['user_role_image']){ ?>
                <dd><img src="<?php echo $post['user_role_image']; ?>" /></dd>
                <?php } ?>
                <?php if(isset($post['user_rank_image']) && $post['user_rank_image']){ ?>
                <dd><img src="<?php echo $post['user_rank_image']; ?>" /></dd>
                <?php } ?>
                <?php if((isset($post['user_rank_stars']) && $post['user_rank_stars']) || (isset($post['user_rank_moons']) && $post['user_rank_moons']) || (isset($post['user_rank_suns']) && $post['user_rank_suns']) || (isset($post['user_rank_crowns']) && $post['user_rank_crowns'])){ ?>
                <dd>
                    <?php for($j=0;$j<$post['user_rank_crowns'];$j++){ ?>
                        <img src="catalog/view/theme/default/image/ranks/crown.png" />
                    <?php } ?>

                    <?php for($k=0;$k<$post['user_rank_suns'];$k++){ ?>
                        <img src="catalog/view/theme/default/image/ranks/sun.png" />
                    <?php } ?>

                    <?php for($l=0;$l<$post['user_rank_moons'];$l++){ ?>
                        <img src="catalog/view/theme/default/image/ranks/moon.png" />
                    <?php } ?>

                    <?php for($m=0;$m<$post['user_rank_stars'];$m++){ ?>
                    <img src="catalog/view/theme/default/image/ranks/star.png" />
                    <?php } ?>
                </dd>
                <dd>
                    <?php echo $text_next_rank; ?>
                    <div style="width:150px;height:15px;border:1px solid #DDD;"><div style="min-width:40px;width:<?php echo $barWidth; ?>px;height:15px;background-color:#5C8AE6;border-bottom:1px solid #4A6EB8;border-right:1px solid #4A6EB8;"><span style="color:#FFFFFF;font-weight:bold;"><?php echo $percentage; ?></span></div></div>
                </dd>
                <?php } ?>
                <dd><?php echo $text_post_num . '&nbsp;'; echo $post['user_posts']; ?></dd>
                <dd><?php echo $text_best_answer_num ?>&nbsp;<span class="highlight-num"><?php echo $post['user_best_answers']; ?></span></dd>
                <dd><?php echo $text_thanks_received_num ?>&nbsp;<span class="highlight-num"><?php echo $post['user_thanks_received']; ?></span></dd>
                <dd><?php echo $text_thanks_given_num ?>&nbsp;<span class="highlight-num"><?php echo $post['user_thanks_given']; ?></span></dd>
                <dd> <?php echo $text_join; ?>&nbsp;<?php echo $post['user_regdate']; ?></dd>
                <?php if($post['user_from']){ ?>
                <dd> <?php echo $text_from; ?>&nbsp;<?php echo $post['user_from']; ?></dd>
                <?php } ?>
                <dd>
                    <?php if($post['user_allow_pm'] && $is_user_login){ ?>
                    <a class="right-pm" href="<?php echo $pm_action_link[$i]; ?>" title="<?php echo $text_pm; ?>"></a>
                    <?php } ?>
                    <?php if($post['user_allow_email'] && $is_user_login){ ?>
                    <a class="right-email" href="mailto:<?php echo $post['user_email']; ?>" title="<?php echo $text_email; ?>"></a>
                    <?php } ?>
                </dd>
            </dl>
        </div>
        <?php $i++; ?>
        <?php } ?>
        <?php if($allow_reply){ ?>
        <a class="reply-button" href="<?php echo $new_reply_link; ?>"></a>
        <?php } ?>
        <div class="forum-pagination"><?php echo $entry_jump; ?>&nbsp;<input type="text" name="page_num_2" value="" onkeydown="if(event.keyCode==13) {window.location='<?php echo $headline_link; ?>&page='+this.value; return false;}" /><input class="input-buttons" style="height:22px;" type="button"  value="<?php echo $text_go; ?>" onclick="window.location='<?php echo $headline_link; ?>&page=' + $('input[name=\'page_num_2\']').attr('value');" /><?php echo $pagination; ?></div>
    </div>
<?php  echo $footer; ?>
<script type="text/javascript" src="catalog/view/javascript/forum_fn.js"></script>
<?php if($show_count_down || $is_your_day_topic){ ?>
<script type="text/javascript" src="catalog/view/javascript/jquery/jquery.countdown.js"></script>
<?php if($show_count_down){ ?>
<script type="text/javascript"><!--//
    $(document).ready(function() {
        $('#counter_poll').countdown({
            digitWidth: 11,
            digitHeight: 16,
            format: 'dd<?php echo $text_days; ?>hh<?php echo $text_hours; ?>mm<?php echo $text_mins; ?>ss<?php echo $text_secs; ?>',
            startTime: '<?php echo $count_down_days; ?><?php echo $text_days; ?><?php echo $count_down_hours; ?><?php echo $text_hours; ?><?php echo $count_down_mins; ?><?php echo $text_mins; ?><?php echo $count_down_secs; ?><?php echo $text_secs; ?>'
        });
    });
//--></script>
<?php } ?>
<?php if($is_your_day_topic) {?>
<script type="text/javascript"><!--//
$(document).ready(function() {
    $('#your-day').countdown({
        digitWidth: 11,
        digitHeight: 16,
        format: 'dd<?php echo $text_days; ?>hh<?php echo $text_hours; ?>mm<?php echo $text_mins; ?>ss<?php echo $text_secs; ?>',
        startTime: '<?php echo $your_day_days; ?><?php echo $text_days; ?><?php echo $your_day_hours; ?><?php echo $text_hours; ?><?php echo $your_day_mins; ?><?php echo $text_mins; ?><?php echo $your_day_secs; ?><?php echo $text_secs; ?>'
    });
});
//--></script>
<?php } ?>
<?php } ?>
<script type="text/javascript"><!--//
<?php if ($text_forum_points_awarded) { ?>
setTimeout(function(){$('#forum-points-awarded').hide();}, 7000);
<?php } ?>

$('#community input[name=\'header-keyword\']').keydown(function(e) {
    if (e.keyCode == 13) {
        $('#header-search-button').trigger('click');
    }
});

$('#header-search-button').bind('click', function() {
    url = 'index.php?route=community/search';

    var keyword = $('#forum-header-bar-search input[name=\'header-keyword\']').attr('value');

    url += '&kw=' + encodeURIComponent(keyword) + '&sw=psm&sb=lpt&or=desc&lr=all';

    location = url;
});
//--></script>
<script type="text/javascript"><!--
$('.popup').colorbox({
    overlayClose: true,
    opacity: 0.5,
    width:500,
    height:600
});
//--></script>